//
// Created by Administrator on 2021/9/16.
//

#include <stdbool.h>
#include <stdio.h>
#include "task1.h"

void task2(){
    initRandSeed();
    while(true) {
        int num1 = getRandNum();
        char op = getRandOp();
        int num2 = getRandNum();
        int answer = 0;
        switch (op) {
            case '+': {
                answer = num1 + num2;
                break;
            }
            case '-': {
                answer = num1 - num2;
                break;
            }
            case '*': {
                answer = num1 * num2;
                break;
            }
            case '/': {
                answer = num1 / num2;
                break;
            }
        }

        printf("%d %c %d = ?", num1, op, num2);
        int stu_answer,attempt=0;
        do {
            if(attempt++==3){
                printf("Wrong! You have tried three times! Test Over!\n");
                return;
            }
            scanf("%d", &stu_answer);
            if (stu_answer == answer) {
                printf("Right!\n");
                break;
            } else {
                printf("Wrong! Try again!\n");
            }
        } while (true);
    }
}